package com.example.yls.wuziqi;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Wanxian on 2018/6/20.
 */

public class Point implements Parcelable {
    private int x;
    private int y;

    public Point() {
    }

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
    public Point(Point src){
        this.x =src.x;
        this.y = src.y;
    }

    protected Point(Parcel in) {
        x = in.readInt();
        y = in.readInt();
    }

    public static final Creator<Point> CREATOR = new Creator<Point>() {
        @Override
        public Point createFromParcel(Parcel in) {
            return new Point(in);
        }

        @Override
        public Point[] newArray(int size) {
            return new Point[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeInt(x);
        parcel.writeInt(y);
    }
    public  final void offset(int dx,int dy){
        x += dx;
        y += dy;
    }
    public final boolean equals(int x,int y){
        return this.x ==x && this.y ==y;
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Point point = (Point) o;

        if (x != point.x) return false;
        if (y != point.y) return false;
        return true;
    }

    @Override
    public int hashCode() {
        int result = x;
        result = 31 * result + y;
        return result;
    }
}
